{template 'public/header'}
{template 'store/nav'}
{template 'store/table-nav'}
<div class="clearfix">
	<div class="panel panel-default">
		<div class="panel-body">
			<ul class="nav nav-pills">
				<li {if $op == 'category_list' ||  $op == 'category_post'}class="active"{/if}><a href="{php echo $this->createWebUrl('table', array('op' => 'category_list'));}">桌台类型</a></li>
				<li {if $op == 'table_list' || $op == 'table_post'}class="active"{/if}><a href="{php echo $this->createWebUrl('table', array('op' => 'table_list'));}">桌台管理</a></li>
			</ul>
			{if $op == 'category_list'}
				<h3>桌台类型 列表</h3>
				<hr>
				<a href="{php echo $this->createWebUrl('table', array('op' => 'category_post'));}" class="btn btn-primary">新建 桌台类型</a>
				<table class="table table-hover table-bordered" style="margin-top:20px">
					<thead>
						<tr>
							<th>名字</th>
							<th>最低消费</th>
							<th>预定预付款</th>
							<th>桌子数量</th>
							<th>操作</th>
						</tr>
					</thead>
					{loop $data $da}
						<tr>
							<td>{$da['title']}</td>
							<td>{$da['limit_price']}</td>
							<td>{$da['reservation_price']}</td>
							<td>{$tables[$da['id']]['num']}</td>
							<td>
								<a href="{php echo $this->createWebUrl('table', array('op' => 'table_post', 'cid' => $da['id']));}" class="btn btn-default">添加桌台</a>
								<a href="{php echo $this->createWebUrl('table', array('op' => 'category_post', 'id' => $da['id']));}" class="btn btn-default">编辑</a>
								<a href="{php echo $this->createWebUrl('table', array('op' => 'category_del', 'id' => $da['id']));}" onclick="if(!confirm('确定删除吗')) return false;" class="btn btn-default">删除</a>
							</td>
						</tr>
					{/loop}
				</table>
			{/if}

			{if $op == 'category_post'}
				<h3>新建 桌台类型</h3>
				<hr>
				<form class="form-horizontal" action="" method="post" id="form-category">
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>名字</label>
						<div class="col-sm-6 col-xs-6">
							<input type="text" class="form-control" name="title" placeholder="" value="{$item['title']}">
						</div>
					</div>			
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>最低消费</label>
						<div class="col-sm-6 col-xs-6">
							<input type="number" class="form-control" name="limit_price" placeholder="例如:2" value="{$item['limit_price']}">
							<span class="help-block"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>预定预付款</label>
						<div class="col-sm-6 col-xs-6">
							<input type="number" class="form-control" name="reservation_price" placeholder="" value="{$item['reservation_price']}">
							<span class="help-block">仅预订订座时需要预付款的金额</span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span></label>
						<div class="col-sm-6 col-xs-6">
							<input type="hidden" name="token" value="{$_W['token']}">
							<input type="submit" name="submit" value="提交" class="btn btn-primary">
						</div>
					</div>
				</form>
			{/if}

			{if $op == 'table_post'}
				<h3>编辑 桌台</h3>
				<hr>
				<form class="form-horizontal" action="" method="post" id="form-set">

					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span></label>
						<div class="col-sm-6 col-xs-6">
							<input type="hidden" name="token" value="{$_W['token']}">
							<input type="submit" name="submit" value="更新 排号模式" class="btn btn-primary">
						</div>
					</div>
				</form>
			{/if}
		</div>
	</div>
</div>
<script type="text/javascript">
require(['clockpicker'], function(){
	$('#form-category').submit(function(){
		if(!$.trim($(':text[name="title"]').val())) {
			util.message('名称不能为空', '', 'error');
			return false;
		}
		return true;
	});
});
</script>
{template 'common'}
{template 'public/footer'}